home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / Virtual User tools / SPEC S&L v.1.0.1 / Scripts / Canvas.vu < prev    next >
Encoding:
Text File  |  1993-12-17  |  10.9 KB  |  292 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:        Canvas.vu
  5. #
  6. #    Contains:    Quick look test script for Canvas version 3.0.4
  7. #
  8. #    Written by:    Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
  9. #
  10. #    Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #     <1.0.6>     9/30/93    KTA        Initialize gFileName prior to gApptitle being updated by
  19. #                                    launchTwitch().
  20. #     <1.0.5>     9/28/93    KTA        Added returnVal for ModifyDocument hook.
  21. #     <1.0.2>     6/16/93    NAGA        Renaming InitGlobals(ScriptLevel)()to InitGlobals(ScriptLevel)()
  22. #        <1+>     5/25/93    NAGA        Adding header and porting old files to follow new standards
  23. #
  24. # ****************************************************************************
  25. #
  26.  
  27.  
  28.  
  29. ########################################################################
  30. #                            External libraries 
  31. #=======================================================================
  32. Libraries "Output.Lib", "DoTasks.Lib","UserInterface.Lib","Draw.Lib", "Da.Lib", "Font.Lib", "Globals.Lib", "LaunchQuit.Lib", "TCS.Lib";
  33.  
  34.  
  35. #########################################################################
  36. ########               Application Specific Tasks
  37. #########################################################################
  38.  
  39. #########################################################################
  40. #                        InitAppGlobals()
  41. #========================================================================
  42. # Author:        ML
  43. # Description:    Sets up tools and fonts for Canvas.  This task
  44. #                must be called first.
  45. # Parameters:    None
  46. # Returns:        Nothing
  47. # Examples:        InitAppGlobals()
  48. #========================================================================
  49. # History:
  50. #
  51. ########################################################################
  52. task InitAppGlobals()
  53. begin
  54.     
  55.     logstr("setting up {global gApptitle}'s globals");            
  56.     global kClick, kDrag, kMultiDrag, kMultiClickDrag, kMultiClick;
  57.     global kPalDocWind, kPalWind, kPullOffPal, kPopUpPal, kScrollPal;
  58.     global kDrawPaletteNum := 1; 
  59.     global kPaintPaletteNum := 2;
  60.     
  61.     global gPaletteList :=    {
  62.                             {                        #### Start Palette #1 - Draw
  63.                             {1,19,50,154,0},        # Location of tab palette relative to the window
  64.                             kPalDocWind,            # Palette type
  65.                             {2,8},                    # Size of Tool matrix {numElemsWide,numElemsTall}
  66.                             {25,17},                # Offset between tools {h,v}
  67.                             0,                        # Not used at this time
  68.                             0                        # Not used at this time
  69.                             },                        #### End Palette #1
  70.                             {                        #### Start Palette #2 - Paint
  71.                             {1,11,200,28},            # Location of alignment palette relative to the window
  72.                             kPalWind,                # Palette type
  73.                             {8,1},                    # Size of Tool matrix {numElemsWide,numElemsTall}
  74.                             {25,0},                    # Offset between tools {h,v}
  75.                             0,                        # Not used at this time
  76.                             0                        # Not used at this time
  77.                             }                        #### End Palette #2
  78.     };
  79.  
  80.     ### Palette Elements:=        Tool#, Pal#,     ToolName,     ToolType,    DblClktoEnd        SetAttributes
  81.     global SelectTool :=         { 1,      1,        "Select",        kClick, 0,                {0}                };
  82.     global LassoTool :=         { 2,      1,        "Lasso",        kClick, 0,                {0}                };
  83.     global TextTool :=             { 3,      1,        "Text",            kClick, 0,                {0}                };
  84.     global FreeHandTool :=         { 4,     1,        "FreeHand",        kDrag,    0,                {0}                };
  85.     global LineTool :=             { 5,      1,        "Line",            kDrag,    0,                {0}                };
  86.     global PolygonTool :=         { 6,      1,        "Polygon",        kMultiClick, 0,            {0}                };
  87.     global RectangleTool :=     { 7,     1,        "Rectangle",    kDrag,    0,                {0}                };
  88.     global PenTool :=             { 8,      1,        "Pen",            kMultiClick, 0,            {0}                };
  89.     global OvalTool :=            { 9,      1,        "Oval",            kDrag,    0,                {0}                };
  90.     global HandTool :=             { 10,     1,        "Hand",            kDrag,    0,                {0}                };
  91.     global CircleTool :=         { 11,     1,        "Circle",        kDrag,     0,                {0}                };
  92.     global MagnifyTool :=         { 12,     1,        "Magnify",        kClick, 0,                {0}                };
  93.     global CurveTool :=         { 13,     1,        "Curve",        kDrag,    0,                {0}                };
  94.     global CubeTool :=             { 15,     1,        "Cube",            kDrag,     1,                {0}                };
  95.  
  96.  
  97.     global PaintLassoTool :=     { 1,     2,        "Paint Lasso",    kClick, 0,                {0}                };
  98.     global DragSelectTool :=     { 2,      2,        "DragSelect",    kDrag,     0,                {0}                };
  99.     global SprayPaintTool :=     { 3,      2,        "Spray Paint",    kDrag,     0,                {0}                };
  100.     global PaintBrushTool :=     { 4,      2,        "Paint Brush",    kDrag,     0,                {0}                };
  101.     global PaintBucketTool :=    { 5,      2,        "Paint Bucket",    kClick, 0,                {0}                };
  102.     global PencilTool :=         { 6,      2,        "Pencil",        kDrag,     0,                {0}                };
  103.     global EraserTool :=         { 7,      2,        "Eraser",        kDrag,     0,                {0}                };
  104.     
  105.     global DrawToolList:={    SelectTool,
  106.                             LassoTool,
  107.                             TextTool,
  108.                             FreeHandTool,
  109.                             LineTool,
  110.                             PolygonTool,
  111.                             RectangleTool,
  112.                             PenTool,
  113.                             OvalTool,
  114.                             HandTool,
  115.                             CircleTool,
  116.                             CurveTool
  117.                         };
  118.  
  119.     global PaintToolList:={    PaintLassoTool,
  120.                             DragSelectTool,
  121.                             SprayPaintTool,
  122.                             PaintBrushTool,
  123.                             PaintBucketTool,
  124.                             PencilTool,
  125.                             EraserTool
  126.                         };
  127.                         
  128.     global gToolList:= DrawToolList;
  129.     # PaintToolList not implemented because gVoidRect is rel to window,
  130.     # descriptor for Paint Tools window is global
  131.     
  132.     global gWindowInset := {56,20,20,20};
  133.     
  134.             ### font characteristic lists
  135.     global gFontSizeList := {'6','9','10','12','14','18','24','36','48','72'};
  136.     global gFontStyleList := {'Bold','Italic','Outline', 'Underline','Shadow',
  137.                             'Superscript','Subscript','Small Caps'};
  138.     
  139.         ### Name of the Plain (style) menu item  ####
  140.     global gPlainStyle := "Plain";            # Plain-Style menu item
  141.  
  142.         ### How to get to the next line
  143.     global gNextLineMethod := 1;            
  144.         ### 1 - ReturnKey,  2 - EnterKey, 3 - DownArrow Key, 4 - TabKey, {} - Move/Click, {'Untitled'} - Move relative to the window titled 'Untitled' /Click
  145.     
  146.         ### Does moving to the next line clear all font info
  147.     global gNextLineClearsFontSettings := 0;
  148.     
  149.         ### Set DoWindows to skip scrolling, scroll bars not recongnized
  150.     global gDoWindowList:= {1,0,1,1};
  151.     
  152. end;    #InitAppGlobals
  153.  
  154. #########################################################################
  155. #                            Views()
  156. #========================================================================
  157. # Author:        ML
  158. # Description:    Change views.
  159. # Parameters:    None
  160. # Returns:        Nothing
  161. # Examples:        Views();
  162. # Assumptions:    None 
  163. # Applications:    Canvas
  164. #========================================================================
  165. # History:
  166. #
  167. #########################################################################
  168. task Views() begin
  169.     LogStr( "Changing Views in Canvas");
  170.     selectMenuItem('Reduce to Fit','Views','Layout');
  171.     selectMenuItem('Home View','Views','Layout');
  172.     selectMenuItem('Zoom In','Views','Layout');
  173.     selectMenuItem('Zoom Out','Views','Layout');
  174. end;
  175.  
  176. #########################################################################
  177. #                            CanvasScroll()
  178. #========================================================================
  179. # Author:        ML
  180. # Description:    Scroll vertically and horizontally, and return
  181. # Parameters:    None
  182. # Returns:        Nothing
  183. # Examples:        CanvaScroll();
  184. # Assumptions:    None 
  185. # Applications:    Canvas
  186. #========================================================================
  187. # History:
  188. #
  189. #########################################################################
  190. task CanvasScroll()
  191. begin
  192.     match[window o:1 s:document c:true z:true g:true r:?ScreenDim];
  193.     WindowRight:= ScreenDim[3];
  194.     WindowBottom:= ScreenDim[4];
  195.     HRightScrollButton:= (WindowRight-10);
  196.     VRightScrollButtonBegin:= 65;
  197.     VRightScrollButtonEnd:= (WindowBottom-40);
  198.     VBottomScrollButton:= (WindowBottom-10);
  199.     HBottomScrollButtonBegin:= 297;
  200.     HBottomScrollButtonEnd:= WindowRight-40;
  201.     
  202.     LogStr("Scroll the window vertically using absolute coordinates");
  203.     MoveMouse(HRightScrollButton,VRightScrollButtonBegin);
  204.     MoveMouse(HRightScrollButton,VRightScrollButtonEnd,,1);
  205.     
  206.     LogStr("Scroll the window horizontally using absolute coordinates");
  207.     MoveMouse(HBottomScrollButtonBegin,VBottomScrollButton);
  208.     MoveMouse(HBottomScrollButtonEnd,VBottomScrollButton,,1);
  209.     
  210.     LogStr("Scroll back to original vertical position");
  211.     MoveMouse(HRightScrollButton,VRightScrollButtonEnd);
  212.     MoveMouse(HRightScrollButton,VRightScrollButtonBegin,,1);
  213.     
  214.     LogStr("Scroll back to original horizontal position");
  215.     MoveMouse(HBottomScrollButtonEnd,VBottomScrollButton);
  216.     MoveMouse(HBottomScrollButtonBegin,VBottomScrollButton,,1);
  217. end;
  218.  
  219.  
  220. #########################################################################
  221. #                            CanvasModifyDocument()
  222. #========================================================================
  223. # Author:        ML
  224. # Description:    Modify Canvas Document
  225. # Parameters:    None
  226. # Returns:        Nothing
  227. # Examples:        CanvasModifyDocument();
  228. # Assumptions:    None 
  229. # Applications:    Canvas
  230. #========================================================================
  231. # History:
  232. #
  233. #########################################################################
  234. task CanvasModifyDocument()
  235. begin
  236.     theReturn := Scrapbook(global kScrapTEXT);
  237.     select [menu t:'File']; # to enable menu items that VU thinks are disabled
  238.     return(theReturn);
  239. end;
  240.  
  241. #########################################################################
  242. #                            CanvasSetupDoText()
  243. #========================================================================
  244. # Author:        ML
  245. # Description:    Setup document for DoText()
  246. # Parameters:    None
  247. # Returns:        Nothing
  248. # Examples:        CanvasSetupDoText();
  249. # Assumptions:    None 
  250. # Applications:    Canvas
  251. #========================================================================
  252. # History:
  253. #
  254. #########################################################################
  255. task CanvasSetupDoText()
  256. begin
  257.     logstr("Setting up for DoText()");
  258.     Draw(global TextTool);
  259. end;
  260.  
  261. ################################################################################
  262. ####################             Main script                    ####################
  263. ################################################################################
  264. script Canvas (ScriptLevel:= -1)
  265. begin
  266.     InitGlobals(ScriptLevel);            # initialize your general globals
  267.     InitDraw();
  268.     InitFonts();
  269.     global gAppTitle := 'Canvas';     # Title of app you will be running
  270.     global gAppVersion := '3.0.3';    # version of app you will be running
  271.     global gFileName := "@!@-{gBuildVers}-{gAppTitle}";    # This is used in SaveAs when saving files
  272.     SuiteStart('Canvas.vu');                    # begin a new test suite
  273.     if LaunchTwitch("{gAppTitle}",gAliasDirectory) # launch or twitch to your app
  274.     begin
  275.         global gModifyDocument:= task CanvasModifyDocument; # define app specific task
  276.         global gSetupDoText:= task CanvasSetupDoText;        # define app specific task
  277.         InitAppGlobals();                                    # init app specific globals
  278.         (*
  279.         *)
  280.         DialogCheck('You have exceeded the user limit.',1);        # Check for Serial number dialog will work with 3.0.3
  281.         DoSetUpApp('No Tools',,,,1,1);
  282.         DoText();
  283.         DoDraw();
  284.         Views();
  285.         CanvasScroll();
  286.         DoWindow();
  287.         select [menu t:'File'];    # to enable menu items that VU thinks are disabled
  288.         DoCloseApp(1);
  289.         logstr("Oh-Oh Toto, I don't think we're in Canvas anymore!");
  290.     end; # if LaunchTwitch("{gAppTitle}",gAliasDirectory)
  291.     SuiteEnd();
  292. end;    #    script Canvas